<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>  
    <%@page import="com.etc.controller.*" %>
<%@page import="com.etc.entity.AnsMessage" %>
<%@page import="com.etc.util.*" %>
<%@page import="com.etc.dao.*" %>
<%@page import="java.util.*" %>
<!DOCTYPE html>
<html>
  
  <head>
    <meta charset="UTF-8">
    <title>管理员-用户管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="./Statics/css/font.css">
    <link rel="stylesheet" href="./Statics/css/xadmin.css">
    <script src="./Statics/js/jquery.min.js"></script>
    <script type="text/javascript" src="./Statics/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="./Statics/js/xadmin.js"></script>
     <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
    <%
  String username = (String)request.getSession().getAttribute("username");
  String role=(String)session.getAttribute("userrole");
  %>
  <body>
    <div class="x-nav">
      <span class="layui-breadcrumb">
        <%
      if(role.equals("admin")){
      %>
        <a href="index_admin.jsp">首页</a>
        <%
      }
      else{
        %>
         <a href="index_user.jsp">首页</a>
         <%
      }
         %>
        <a href="">演示</a>
        <a>
          <cite>导航元素</cite></a>
      </span>
      <a class="layui-btn layui-btn-primary layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:38px">ဂ</i></a>
    </div>
    <div class="x-body">
      <div class="layui-row">
        <form class="layui-form layui-col-md12 x-so" action="MyListAnsMessageServlet" method="get">
        <input type="hidden" name="pageIndex" value=1>
        <input type="hidden" name="username" value="<%=username%>">
          <input type="text" name="search"  placeholder="请输入内容" autocomplete="off" class="layui-input">
          <input type="submit" class="layui-btn"  lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i>
        </form>
      </div>
      <xblock>
        <button class="layui-btn layui-btn-danger" onclick="delAll()"><i class="layui-icon"></i>批量封禁</button>
<!--         <button class="layui-btn" onclick="x_admin_show('添加用户','./html/admin-add.jsp')"><i class="layui-icon"></i>添加</button> -->
        <span class="x-right" style="line-height:40px">共有数据${list.size()}条
        </span>
      </xblock>
      <table class="layui-table">
        <thead>
          <tr>
            <th>
              标题
            </th>
            <th>内容</th>
            <th>回复时间</th>
            <th>状态</th>
            <th>操作</th>
        </thead>
        <tbody>
        <%
        PageTool pageTool = (PageTool)request.getAttribute("amlist");
        List<AnsMessage> list = pageTool.getList();
        for(int i=0;i<list.size();i++)
        {
        	request.setAttribute("list", list.get(i));
        %>
          <tr>
           <td>${list.title}</td>
           <td>${list.content}</td>
           <td>${list.date }</td>
           <td>${list.status }</td>
            <td class="td-manage">
              <a title= "解禁"  onclick="member_jie(this,'${list.id}')"  href="javascript:;">
<!--                 <i class="layui-icon">&#xe642;</i> -->
					解禁
              </a>
              <a title= "封禁"  onclick="member_del(this,'${list.id}')"  href="javascript:;">
<!--                 <i class="layui-icon">&#xe640;</i> -->
					封禁
              </a>
            </td>
          </tr>
          <%
          }
          %>
        </tbody>
      </table>
      <div style="height:50px;line-height:50px;text-align:center;" class="page">
      <%
 int pageindex = pageTool.getPageIndex();
 int pagetotal = pageTool.getTotalPage();
 
 
 if(pageindex>1){
 %>
	<a href="AnsMessageServlet?am=myans&username=<%=username %>&pageIndex=1">首页</a>
	<a href="AnsMessageServlet?am=myans&username=<%=username %>&pageIndex=<%=pageindex-1%>">上一页</a>
	<%
 }
	%>
	<%
	if(pageindex<pagetotal){
	%>
	<a href="AnsMessageServlet?am=myans&username=<%=username %>&pageIndex=<%=pageindex+1%>">下一页</a>
	<%
	}
	%>
	<%
	if(pageindex!=pagetotal){
	%>
	<a href="AnsMessageServlet?am=myans&username=<%=username %>&pageIndex=<%=pagetotal%>">末页</a>
	  <%
	}
	  %>
<!--       <div class="page"> -->
<!--         <div> -->
<!--           <a class="prev" href="">&lt;&lt;</a> -->
<!--           <a class="num" href="">1</a> -->
<!--           <span class="current">2</span> -->
<!--           <a class="num" href="">3</a> -->
<!--           <a class="num" href="">489</a> -->
<!--           <a class="next" href="">&gt;&gt;</a> -->
<!--         </div> -->
<!--       </div> -->

    </div>
    <script>
      layui.use('laydate', function(){
        var laydate = layui.laydate;
        
        //执行一个laydate实例
        laydate.render({
          elem: '#start' //指定元素
        });

        //执行一个laydate实例
        laydate.render({
          elem: '#end' //指定元素
        });
      });
      
      /*用户-封禁*/
      function member_del(obj,id){
          layer.confirm('确认要封禁吗？',function(index){
           window.location.href="AnsMessageServlet?am=feng&type=my&id="+id;
              //layer.msg('已删除!',{icon:1,time:1000});
          });
      }
      
      /*用户-解禁*/
      function member_jie(obj,id){
          layer.confirm('确认要解禁吗？',function(index){
           window.location.href="AnsMessageServlet?am=jie&type=my&id="+id;
              //layer.msg('已删除!',{icon:1,time:1000});
          });
      }
      /*用户-封禁全部*/
      function delAll (argument) {
        var data = tableCheck.getData();
        layer.confirm('确认要封禁全部吗？'+data,function(index){
            //捉到所有被选中的，发异步进行删除
            layer.msg('操作成功', {icon: 1});
            $(".layui-form-checked").not('.header').parents('tr').remove();
        });
      }
    </script>
  </body>

</html>